package Spil;

import desktop_resources.GUI;

public class LaborCamp extends Ownable {

	private final int diceMultiplyer = 100;
	private String Answer;
	private Cup cup = new Cup();
	private Dice dice = new Dice();

	public LaborCamp(int price, String Name, int id){
		super.setPrice(price);
		super.setName(Name);
		super.setId(id);
		super.setType("LaborCamp");
	}

	@Override
	public int getRent() {
		if (super.getOwner() != null) {
			return cup.getSum() * diceMultiplyer * super.getOwner().getCampsOwned();
		}
		else
			return 0;
	}

	@Override
	public void landOnField(Player player) {
		if (player == super.getOwner())
			GUI.displayChanceCard(Txt.Owner);
		else {
			if(super.isOwned())
			{
				GUI.getUserButtonPressed(Txt.RollAgain, Txt.Roll);
				cup.rollDice(dice.roll(), dice.roll());
				GUI.displayChanceCard(Txt.Owned + super.getOwner().toString() + Txt.Owned2 + getRent());
				player.addBalance(-getRent());
				super.getOwner().addBalance(getRent());
			}
			else
			{
				Answer = GUI.getUserButtonPressed(Txt.Buy + getPrice(), Txt.Yes, Txt.No);
				if(Answer == Txt.Yes) {
					GUI.setOwner(player.getFieldNumber(), player.toString());
					super.setOwner(player);
					player.addBalance(-getPrice());
					player.addCampsOwned(); 
				}
			}
		}
	}

	@Override
	public void removeOwner(Player player, int fieldNumber) {
		if (super.getOwner() == player) {
			super.setOwner(null);
			GUI.removeOwner(fieldNumber + 1);
		}
	}

}
